home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / ploterr.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  104 lines

  1. ; $Id: ploterr.pro,v 1.3 1996/12/17 20:21:56 ali Exp $
  2.  
  3. PRO PLOTERR,X,Y,ERR, psym = PSYM, type = TYPE
  4. ;
  5. ;+
  6. ; NAME:
  7. ;    PLOTERR
  8. ;
  9. ; PURPOSE:
  10. ;    Plot data points with accompanying error bars.
  11. ;    (See also OPLOTERR.)    
  12. ;
  13. ; CATEGORY:
  14. ;    Plotting, two-dimensional.
  15. ;
  16. ; CALLING SEQUENCE:
  17. ;    PLOTERR, [ X ,]  Y , Err [, PSYM = Psym] [, TYPE = Type]
  18. ;
  19. ; INPUTS:
  20. ;    X:    The array of abcissae.
  21. ;
  22. ;    Y:    The array of Y values.
  23. ;
  24. ;    Err:    The array of error-bar values.
  25. ;
  26. ; OPTIONAL KEYWORD PARAMETERS:
  27. ;    PSYM:    The plotting symbol to use.  The default is +7.
  28. ;
  29. ;    TYPE:    The type of plot to be produced.  The possible types are:
  30. ;            TYPE = 0 :    X Linear - Y Linear (default)
  31. ;            TYPE = 1 :    X Linear - Y Log
  32. ;            TYPE = 2 :    X Log    - Y Linear
  33. ;            TYPE = 3 :    X Log    - Y Log
  34. ;
  35. ; COMMON BLOCKS:
  36. ;    None.
  37. ;
  38. ; SIDE EFFECTS:
  39. ;    None.
  40. ;
  41. ; RESTRICTIONS:
  42. ;    Arrays cannot be of type string.  There must be enough points to
  43. ;    plot.
  44. ;
  45. ; PROCEDURE:
  46. ;    A plot of X versus Y with error bars drawn from Y - ERR to Y + ERR
  47. ;    is written to the output device.
  48. ;
  49. ; MODIFICATION HISTORY:
  50. ;    William Thompson    Applied Research Corporation
  51. ;    July, 1986        8201 Corporate Drive
  52. ;                Landover, MD  20785
  53. ;
  54. ;    DMS, April, 1989    Modified for Unix.
  55. ;-
  56. ;
  57. ;P_SYM = !PSYM        ; Save the affected system parameters
  58. ;Y_MIN = !YMIN
  59. ;Y_MAX = !YMAX
  60. ;BANG_C = !C
  61. ;LINETYPE = !LINETYPE
  62. ;
  63. ;  Interpret the input parameters.
  64. ;
  65. if n_elements(type) eq 0 then type = 0
  66. if n_elements(psym) eq 0 then psym = 7
  67.  
  68. ON_ERROR,2
  69. NP = N_PARAMS(0)
  70. IF NP LT 2 THEN BEGIN
  71.     message,'Must be called with 2-5 parameters: [X,] Y, ERR [,PSYM [,TYPE]]'
  72.     RETURN
  73. ENDIF ELSE IF NP EQ 2 THEN BEGIN    ;Only Y and ERR passed.
  74.     YERR = ABS(Y)
  75.     YY = X
  76.     XX = INDGEN(N_ELEMENTS(YY))
  77. ENDIF ELSE BEGIN
  78.     YERR = ABS(ERR)
  79.     YY = Y
  80.     XX = X
  81. ENDELSE
  82. ;
  83. N = N_ELEMENTS(XX) < N_ELEMENTS(YY) < N_ELEMENTS(YERR)
  84. IF N LT 2 THEN message, 'Not enough points to plot.'
  85.  
  86. XX = XX[0:N-1]
  87. YY = YY[0:N-1]
  88. YERR = YERR[0:N-1]
  89. YLO = yy - yerr
  90. YHI = yy + yerr
  91. ;    Set yrange if not already set
  92. if !y.range[0] eq !y.range[1] then $    ;yrange specified?
  93.     yrange = [ min(ylo), max(yhi) ] $
  94.  else yrange = !y.range
  95. ;
  96. plot,xx,yy,xtype = type/2, ytype = type and 1, yrange = yrange, psym=psym
  97. ;
  98. ;  Plot the error bars.
  99. ;
  100. FOR I = 0,N-1 DO plots,[xx[i],xx[i]], [ylo[i], yhi[i]]
  101. RETURN
  102. END
  103.  
  104.